//
//  ViewController.m
//  CALScanQRCode
//
//  Created by Cain on 5/2/16.
//  Copyright © 2016 Cain. All rights reserved.
//

#import "CALScanQRCodeExampleViewController.h"
#import "HttpTool.h"
#import "BindVC.h"
@interface CALScanQRCodeExampleViewController ()

@end

@implementation CALScanQRCodeExampleViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    __weak typeof(self) weakSelf = self;
    [self setCalScanQRCodeGetMetadataStringValue:^(NSString *stringValue) {
        NSLog(@"二维码的值 ==== %@",stringValue);
        BindVC *bindVc =[[BindVC alloc]init];
        bindVc.bindInfo=stringValue;
        [weakSelf.navigationController pushViewController: bindVc animated:YES];
    }];
    
   
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


-(void)bindWatchToserver:(NSString *)watch_sn with:(NSString *)device_sn and:(NSString*)phone_ease_userid by:(NSString*)device_model{
    NSString *url =[apiUrl stringByAppendingString:bindWatch];
    NSDictionary *paramerter =@{@"watch_sn":watch_sn,@"device_sn":device_sn,@"phone_ease_userid":phone_ease_userid,@"device_model":device_model};
   [HttpTool Post:url parameters:paramerter success:^(id responseObject) {
       //上传给服务器
       NSLog(@"bindWatchToserver----=== %@",responseObject);
   } failure:^(NSError *error) {
       
   }];
}
-(void)getBindByServer:(NSString *)device_sn{
    NSString *url =[apiUrl stringByAppendingString:getBind];
      NSDictionary *paramerter =@{@"device_sn":device_sn};
    [HttpTool GET:url WithHeader:false parameters:paramerter success:^(id responseObject) {
        NSLog(@"getbind----=== %@",responseObject);
    } failure:^(NSError *error) {
        
    }];
}
-(void)unbindWatchToserver:(NSString *)watch_sn with:(NSString *)device_sn{
    NSString *url =[apiUrl stringByAppendingString:bindWatch];
    NSDictionary *paramerter =@{@"watch_sn":watch_sn,@"device_sn":device_sn};
    [HttpTool Post:url parameters:paramerter success:^(id responseObject) {
        //上传给服务器
        NSLog(@"unbindWatchToserver----=== %@",responseObject);
    } failure:^(NSError *error) {
        
    }];
}

@end
